<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: listproducts.php 63 2013-09-21 11:59:19Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 63 $
* 	zuletzt geaendert von:	$Author: peter $
* 	Datum:					$Date: 2013-09-21 11:59:19 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

require('includes/application_top.php');
?>
<!DOCTYPE html>
<html>
	<head>
		<title>Valid Categories/Products List</title>
		<style type="text/css">
		<!--
		h4 {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: x-small; text-align: center}
		p {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small}
		th {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small}
		td {  font-family: Verdana, Arial, Helvetica, sans-serif; font-size: xx-small}
		-->
		</style>
	<head>
	<body>
	<table width="550" border="1" cellspacing="1" bordercolor="gray">
		<tr>
			<td colspan="3"><h4>Valid Products List</h4></td>
		</tr>
	<?
	   $get_result = $db->db_query("SELECT restrict_to_products,restrict_to_categories FROM ".TABLE_COUPONS."  WHERE coupon_id='".$_GET['cid']."'");
	
	    echo '	<tr>
	    			<th>Product ID</th>
	    			<th>Product Name</th>
	    			<th>Product Size</th>
	    		</tr>
	    		<tr>';
	    
	    $pr_ids = explode(",", $get_result->fields['restrict_to_products']);
	    
		for ($i = 0; $i < count($pr_ids); $i++) {
			$row = $db->db_query("	SELECT 
										* 
									FROM 
										".TABLE_PRODUCTS." p, 
										".TABLE_PRODUCTS_DESCRIPTION." pd 
									WHERE 
										p.products_id = pd.products_id 
									AND 
										pd.language_id = '".$_SESSION['languages_id']."' 
									AND 
										p.products_id = '".$pr_ids[$i]."'");
			
			if ($row->_numOfRows) {
				echo "<td>".$row->fields['products_id']."</td>\n";
				echo "<td>".$row->fields['products_name']."</td>\n";
				echo "<td>".$row->fields['products_model']."</td>\n";
				echo "</tr>\n";
			}
		}
	      echo "</table>\n";
	?>
	<br />
	<table width="550" border="0" cellspacing="1">
		<tr>
			<td align=middle><input type="button" value="Close Window" onClick="window.close()"></td>
		</tr>
	</table>
	</body>
</html>